#include "logmanager.h"
#include <QDebug>


QMap<QString,Logger *> LogManager::missionLogMap = QMap<QString,Logger *>();

LogManager::LogManager() {}


/**
 * 结构化日志的六大元素
 * "[time] [level] [tag] [task] [step] [content]"
 * @brief LogManager::debug
 * @param module
 * @param task
 * @param string
 */

QString Mission = "";
 void LogManager::debug(QString module, QString task,QString taskState,QString content) {
    QString fmt = "[%1] [time] [Debug] [%2] [%3] [%4] [%5]";
    QString log = fmt.arg(Mission,module,task,taskState,content);
    qDebug() << log;
}

 Logger * LogManager::getMissionLogger(QString mission) {
     if(missionLogMap.contains(mission)) {
         return missionLogMap.value(mission);
     }
     else {
         Logger * logger = new Logger();
         logger->mission = mission;
         missionLogMap.insert(mission,logger);
         return logger;
     }
 }

